package com.dhj;

import org.apache.commons.io.FileUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import java.io.File;


/**
 * @author DaHuaJia
 * @Description 解析字符串
 * @Date 2021-11-13 13:56:24
 */
public class TestString {

    public static void main(String[] args) throws Exception{
        // 使用工具类读取文件获取字符串
        String content = FileUtils.readFileToString(new File("D:\\FreeSpace\\2021\\crawler\\secondCrawler\\src\\main\\resources\\ningmeng.html"), "utf8");

        // 输出字符串内容
        System.out.println(content);

        // 解析字符串
        Document doc = Jsoup.parse(content);

        String title = doc.getElementsByTag("title").first().text();
        System.out.println(title);

    }

}
